home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / mintprgs / mintupgr / disk8.zoo / ash.zoo / usr / doc / ash / dump < prev    next >
Text File  |  1992-05-04  |  3KB  |  88 lines

  1. #!/bin/sh
  2. # make incremental dump of filesystems
  3. # usage: dump level filesystem...
  4. #
  5. # Dumps are made on $dumpdev, which contains a directory for every filesystem
  6. # dumped.  Of course, you cannot dump that filesystem itself.  For example,
  7. # if dumpdev=/dev/g, there will be the following directories:
  8. #   /dev/g/c
  9. #   /dev/g/d
  10. # et cetera.  Each such directory contains a file named YYYYMMDD.tar, where
  11. # YYYYMMDD is the date of the dump.  If you dump /dev/c on 03 May, 1992,
  12. # there will be a file /dev/g/c/19920503.tar
  13. version="0.0 alpha"
  14. PATH=${root}/bin:${root}/usr/bin
  15. set -e
  16. # set -x # Uncomment this line when debugging
  17. umask 022
  18. dumpdev=/dev/g
  19. root=u:
  20. datesfile=${root}/etc/dumpdate
  21. infofile=${root}/etc/dumpinfo
  22.  
  23. fatalerror () {
  24.   echo Dump aborted on `ddate` due to a signal >> $infofile
  25. }
  26.  
  27. # Print message on fatal signal
  28. trap fatalerror 2 3 4 5 6 7 8 10 11 12 13 15
  29.  
  30. echo Dump script version $version, Stephan Neuhaus for MiNT/TOS
  31. program=$0
  32. level=$1 ; shift
  33.  
  34. if test ! -d $dumpdev -a ! -b  $dumpdev ; then
  35.   echo program: Dump device $dumpdev: not a directory nor block special file
  36.   exit 1
  37. fi
  38.  
  39. for dumpdir in $* ; do
  40.   filesystem=/dev/${dumpdir}
  41.   if test ! -d $filesystem -a ! -b $filesystem ; then
  42.     echo $program: Source $filesystem: not a directory nor block special file
  43.     exit 1
  44.   fi
  45.   
  46.   if test $level != 0 ; then
  47.     lastdate=`gawk '
  48.       BEGIN { found = 0 }
  49.       $1 == level - 1 && $6 == filesystem { lastdate=$4; lasttime=$5; found=1 }
  50.       END { if (found) printf "%s %s", lastdate, lasttime; }' \
  51.       level=${level} filesystem=${filesystem} ${datesfile}`
  52.  
  53.       if test "x${lastdate}" -eq x ; then
  54.         echo Previous dump not found in ${datesfile}
  55.         exit 1
  56.       fi
  57.   fi
  58.   startdate=`ddate`
  59.   dumpdate=`echo $startdate | cut --delimiter=' ' --fields=1 | gawk -F / '{printf "%s%s%s", $3, $1, $2}'`
  60.   echo Begin of dump info for level $level dump of $filesystem >> $infofile
  61.   echo Level $level dump of $filesystem started on $startdate >> $infofile
  62.   echo -n Dumping $filesystem...
  63.   dumpfile=${dumpdev}/${dumpdir}/${dumpdate}.tar
  64.   if test ! -d ${dumpdev}/${dumpdir} ; then
  65.     mkdir ${dumpdev}/${dumpdir}
  66.   fi
  67.   cd $filesystem
  68.   if test $level == 0 ; then
  69.     tar +create +file $dumpfile .
  70.   else
  71.     tar +create +newer "$lastdate" +file $dumpfile .
  72.   fi
  73.   enddate=`ddate`
  74.   echo $level $startdate $enddate $filesystem >> ${datesfile}
  75.   echo -n Writing filelist...
  76.   echo List of files follows: >> $infofile
  77.   tar +list +verbose +file $dumpfile >> $infofile
  78.   echo Level $level dump of $filesystem ended on $enddate \(written on ${dumpfile}\) >> $infofile
  79.   ls -l $dumpfile >> $infofile
  80.   echo -n Compressing...
  81.   compress -f $dumpfile
  82.   cfile=`echo $dumpfile | sed s/tar/taz/g`
  83.   ls -l $cfile >> $infofile
  84.   echo End of dump info for level $level dump of $filesystem >> $infofile
  85.   echo Done.
  86. done
  87. echo Done.
  88.